from socket import *

clientSock = socket(AF_INET,SOCK_STREAM)
serAddr = ("192.168.31.108",5000)
clientSock.connect(serAddr)

while True:
    sendData = input("请输入要发送的数据：")
    clientSock.send(sendData.encode("gb2312"))
    if sendData == '\r':
        break
clientSock.close()